//
//  ShipingHeaderView.m
//  B段项目
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 徐茂怀. All rights reserved.
//

#import "ShipingHeaderView.h"
#define POSTURL @"http://api.haodou.com/index.php?appid=2&appkey=9ef269eec4f7a9d07c73952d06b5413f&format=json&sessionid=1446510860323&vc=77&vn=5.4.0&loguid=0&deviceid=haodou99000505722929&uuid=a6afb132369a979ba3427eec69189063&channel=xiaomi_v540&method=Info.getVideoIndexData&virtual=&signmethod=md5&v=2&timestamp=1446521807&nonce=0.5540476473852274&appsign=ee43f17e3c8f395a381ae816403e0d1b"
#import "ShipingHeaderView.h"
#import "FitHeader.h"
#import "UIImageView+WebCache.h"
@implementation ShipingHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
        [self getData];
    }
    return self;
}

-(void)getData
{
    [XMHNetWorkongMethods getDataVyString:POSTURL BodyString:[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"offset", nil] WithDataBlock:^(id data) {
        NSDictionary *dic = [data objectForKey:@"result"];
        _dataDic = [dic objectForKey:@"focus_recommend"];
        [_myImageView sd_setImageWithURL:[NSURL URLWithString:[_dataDic objectForKey:@"Cover"]]];
        _tuiJianLabel.text = [_dataDic objectForKey:@"Card"];
        _titleLabel.text = [_dataDic objectForKey:@"Title"];
        _contentLabel.text = [_dataDic objectForKey:@"Desc"];
    }];
}

-(void)createView
{
    _myImageView = [[UIImageView alloc]init];
    _tuiJianLabel = [[UILabel alloc]init];
    _tuiJianLabel.font = [UIFont fontWithName:@"EuphemiaUCAS-Bold" size:20 * FitWidth];
    _tuiJianLabel.textColor = [UIColor whiteColor];
    _tuiJianLabel.textAlignment = 1;
    _tuiJianLabel.backgroundColor = [UIColor colorWithRed:0.12 green:0.63 blue:0.59 alpha:1];
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.font = [UIFont fontWithName:@"EuphemiaUCAS-Bold" size:25 * FitWidth];
    _contentLabel = [[UILabel alloc]init];
    _contentLabel.font = [UIFont fontWithName:@"Helvetica-LightOblique" size:17];
    _contentLabel.numberOfLines = 0;
    
    [self addSubview:_myImageView];
    [self addSubview:_tuiJianLabel];
    [self addSubview:_titleLabel];
    [self addSubview:_contentLabel];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    _myImageView.frame = CGRectMake(0, 0, self.frame.size.width, 250 * FitHeight);
    _tuiJianLabel.frame = CGRectMake(10 * FitWidth, _myImageView.frame.origin.y + _myImageView.frame.size.height + 10 * FitHeight, 80 * FitWidth, 23 * FitHeight);
    _titleLabel.frame = CGRectMake(_tuiJianLabel.frame.origin.x + _tuiJianLabel.frame.size.width + 10 * FitWidth, _tuiJianLabel.frame.origin.y, 200 * FitWidth, 20 * FitHeight);
    _contentLabel.frame = CGRectMake(_tuiJianLabel.frame.origin.x, _tuiJianLabel.frame.origin.y + _tuiJianLabel.frame.size.height + 20 * FitHeight, 355 * FitWidth, 50 * FitHeight);
}

@end
